Completed
Push — 190-feature/delete-posts-by-cu... ( 68d026...3b8c06 )
by Sudar
06:00 queued 03:07
created

$(document).ready   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 42
rs 8.8571
c 1
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A 0 7 1
A 0 13 2
1
/**
2
 * Add select2 functionality..
3
 */
4
/*global ajaxurl*/
5
jQuery( document ).ready( function () {
6
	/**
7
	 * Normal select2.
8
	 */
9
	jQuery( '.select2-taxonomy' ).select2( {
10
		width: '300px'
11
	} );
12
13
	/**
14
	 * Enable AJAX for Taxonomy Select2.
15
	 */
16
	jQuery( '.select2-taxonomy-ajax' ).select2( {
17
		ajax: {
18
			url: ajaxurl,
19
			dataType: 'json',
20
			delay: 250,
21
			data: function ( params ) {
22
				return {
23
					q: params.term,
24
					taxonomy: jQuery( this ).attr( 'data-taxonomy' ),
25
					action: 'bd_load_taxonomy_term'
26
				};
27
			},
28
			processResults: function ( data ) {
29
				var options = [];
30
31
				if ( data ) {
32
					jQuery.each( data, function ( index, dataPair ) {
33
						options.push( { id: dataPair[ 0 ], text: dataPair[ 1 ] } );
34
					} );
35
				}
36
37
				return {
38
					results: options
39
				};
40
			},
41
			cache: true
42
		},
43
		minimumInputLength: 2, // the minimum of symbols to input before perform a search
44
		width: '300px'
45
	} );
46
} );
47